class ApplicationController < ActionController::Base
  protect_from_forgery
	before_filter :authorize
	public
		
		def current_configurator
			Configurator.find(session[:configurator_id])
		rescue ActiveRecord::RecordNotFound
			configurator = Configurator.create
			session[:configurator_id] = configurator.id
			configurator
		end


  protected

    def authorize 
      unless User.find_by_id(session[:user_id])
        redirect_to login_url, notice: 'No tiene acceso a este recurso' 
      end
    end 

end
